import {IsNotEmpty, IsOptional, IsString, Matches} from 'class-validator';

export class UserDto {
  @IsNotEmpty({ message: '用户名不能为空' })
  @IsString({ message: '用户名必须是字符串' })
  username: string;

  @IsNotEmpty({ message: '密码不能为空' })
  @IsString({ message: '密码必须是字符串' })
  @Matches(/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,}$/, {
    message: '密码必须至少6位，包含字母和数字',
  })
  password: string;

  @IsOptional()
  @IsString({ message: 'avatar必须是字符串' })
  @Matches(/\.(jpg|png|jpeg)$/, { message: '文件格式错误' })
  avatar: string
}
